<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:totoland="http://java.sun.com/jsf/composite/components">
    <h:head>               
    </h:head>
    <h:body>
        <ui:composition template="/template/etcTemplateGreen.xhtml">
            <ui:define name="content">
                <h:form id="form1" prependId="false">
                    <p:panel header="หน้าออกรายงาน #{msg.report_001_summary_label}">
                        <p:panelGrid columns="4" style="width: 100%;" styleClass="frmSelect" id="searchCriteria">
                            <f:facet name="header">เงื่อนไขการแสดงรายงาน</f:facet>     
                            <p:outputLabel value="#{msg.label_fiscal_year} :" />
                            <p:selectOneMenu style="width: 220px;" value="#{report001SummaryController.reportCriteria.year}">
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{report001SummaryController.dropdownFactory.ddlFiscalYear()}"></f:selectItems>  
                            </p:selectOneMenu>
                            <p:outputLabel value="เลือกเดือน : " />
                            <p:selectOneMenu style="width: 220px;" value="#{report001SummaryController.reportCriteria.month}">  
                                <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="" />  
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{report001SummaryController.dropdownFactory.ddlMonth()}"></f:selectItems>
                            </p:selectOneMenu>  
                            <p:outputLabel value="เลือกประเภทรายงานผลการปฏิบัติการ : " rendered="false"/>
                            <p:selectOneMenu style="width: 220px;" rendered="false">  
                                <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="" />  
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{report001SummaryController.dropdownFactory.ddlReportOperating()}"></f:selectItems> 
                            </p:selectOneMenu>  
                            <p:outputLabel value="เลือกแบบรายงาน : " rendered="false"/>
                            <p:selectOneMenu style="width: 220px;" rendered="false">  
                                <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="" />
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{report001SummaryController.dropdownFactory.ddlReportForm()}"></f:selectItems>  
                            </p:selectOneMenu>  
                            <p:outputLabel value="เลือกยุทธศาสตร์ที่ : "/>
                            <p:selectOneMenu style="width: 220px;" id="REPORT_001strategicId" value="#{report001SummaryController.reportCriteria.strategic}" >  
                                <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="-1" />
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" 
                                               value="#{report001SummaryController.dropdownFactory.ddlStrategic()}">
                                </f:selectItems>
                                <p:ajax update="searchCriteria"/>  
                            </p:selectOneMenu>
                            <p:outputLabel value="เลือกกลยุทธ์ : " id="REPORT_001subStrategicId" />
                            <p:selectOneMenu style="width: 220px;" id="subStrategicId" value="#{report001SummaryController.reportCriteria.subStrategic}" >  
                                <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="-1" />  
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{report001SummaryController.dropdownFactory.ddlSubStrategic(report001SummaryController.reportCriteria.strategic)}"></f:selectItems>
                                <p:ajax update="searchCriteria"/>
                            </p:selectOneMenu>
                            <p:outputLabel value="เลือกแผนงาน : " />
                            <p:selectOneMenu style="width: 220px;" id="REPORT_001planId" value="#{report001SummaryController.reportCriteria.plan}">  
                                <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="-1" />  
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{report001SummaryController.dropdownFactory.ddlPlan(report001SummaryController.reportCriteria.subStrategic)}"></f:selectItems>  
                                <p:ajax update="searchCriteria"/>
                            </p:selectOneMenu>
                            <p:outputLabel value="เลือกโครงการ : " />
                            <p:selectOneMenu style="width: 220px;" id="REPORT_001projectId"  value="#{report001SummaryController.reportCriteria.project}" >  
                                <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="-1" />  
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{report001SummaryController.dropdownFactory.ddlProject(report001SummaryController.reportCriteria.plan)}"></f:selectItems> 
                                <p:ajax update="searchCriteria"/>
                            </p:selectOneMenu>
                            <p:outputLabel value="เลือกกิจกรรม : " />
                            <p:selectOneMenu style="width: 220px;" id="REPORT_001Activity" value="#{report001SummaryController.reportCriteria.activity}" >  
                                <f:selectItem itemLabel="#{msg.ddl_select}" itemValue="" />  
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{report001SummaryController.dropdownFactory.ddlActivity(report001SummaryController.reportCriteria.project)}"></f:selectItems> 
                            </p:selectOneMenu>                            
                            <h:outputLabel value="หน่วยงาน" rendered="#{report001SummaryController.canSearchUserGroup()}"/>
                            <p:selectCheckboxMenu id="ectDllUserGrp2" value="#{report001SummaryController.selectedGroup}" label="หน่วยงาน"
                                                  style="width: 220px" filter="true" filterMatchMode="startsWith" panelStyle="width:auto">
                                <f:selectItems itemLabel="#{item.name}" itemValue="#{item.value}" var="item" value="#{report001SummaryController.dropdownFactory.ddlUserGroup()}"/>  
                            </p:selectCheckboxMenu>
                            <h:panelGroup rendered="#{report001SummaryController.canSearchUserGroup()}"/>
                            <h:panelGroup rendered="#{report001SummaryController.canSearchUserGroup()}"/>

                            <f:facet name="footer">
                                <div align="center">
                                    <p:commandButton id="btnShowRpt" action="#{report001SummaryController.search()}" update="pnRptPreSendList2" process="searchCriteria" value="แสดงรายงาน"/>
                                    <p:commandButton id="downloadAlldetail" value="#{msg.label_download_all_detail}" icon="ui-icon-arrowthichk-s" action="#{report001SummaryController.searchDetail()}" update="pnRptPreSendList2" process="searchCriteria"/>
                                    <p:commandButton id="btnResetwRpt" action="#{report001SummaryController.resetForm()}" update="searchCriteria,pnRptPreSendList2" value="เริ่มใหม่"/>
                                </div>
                            </f:facet>
                        </p:panelGrid><br/>
                        <h:panelGroup id="pnRptPreSendList2">
                            <p:panel style="text-align: right">
                                <p:commandButton id="downloadLink" value="#{msg.label_download}" ajax="false" action="#{report001SummaryController.fileXLSDownload()}"   
                                                 icon="ui-icon-arrowthichk-s" rendered="#{report001SummaryController.lazyModel!=null || report001SummaryController.lazyModelDetail!=null}">
                                </p:commandButton>
                            </p:panel>
                            <p:dataTable id="rptPreSendList2" var="item" value="#{report001SummaryController.lazyModel}" rendered="#{!report001SummaryController.viewDetail}"
                                         paginator="true" rows="10" lazy="true" emptyMessage="#{msg.no_data_found}" rowIndexVar="index"
                                         currentPageReportTemplate="#{msg.current_pagereport_template}" resizableColumns="true"
                                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                         rowsPerPageTemplate="10,15,20">

                                <p:columnGroup type="header">  
                                    <p:row>  
                                        <p:column rowspan="2" headerText="หน่วยงาน" /> 
                                        <p:column rowspan="2" headerText="เลือกยุทธศาสตร์" />
                                        <p:column rowspan="2" headerText="กลยุทธ์" />
                                        <p:column rowspan="2" headerText="แผนงาน" />
                                        <p:column rowspan="2" headerText="โครงการ" />
                                        <p:column rowspan="2" headerText="รายละเอียดกิจกรรม" />
                                        <p:column rowspan="1" colspan="3" headerText="เป้าหมาย" />
                                        <p:column rowspan="1" colspan="2" headerText="ตัวชี้วัดโครงการ/กิจกรรม" />
                                        <p:column rowspan="1" colspan="2" headerText="งบประมาณ" />
                                        <p:column rowspan="2" headerText="ร้อยละ" />
                                        <p:column rowspan="1" colspan="1" headerText="การบรรลุตัวชี้วัด" />
                                    </p:row>  

                                    <p:row>  
                                        <p:column headerText="หน่วยนับ" />  
                                        <p:column headerText="แผน" />
                                        <p:column headerText="ผล" />
                                        <p:column headerText="ตัวชี้วัด (แผน)" />
                                        <p:column headerText="ตัวชี้วัด (ผล)" />
                                        <p:column headerText="ตั้งไว้" />
                                        <p:column headerText="จ่ายจริง" />
                                        <p:column colspan="1" headerText="ผ่าน/ไม่ผ่าน" />
                                    </p:row>
                                </p:columnGroup>
                                <p:column>
                                    <h:outputText value="#{item.userGroupName}" />
                                </p:column>

                                <p:column width="20">  
                                    <h:outputText value="#{item.strategicName}" />
                                </p:column>
                                
                                <p:column width="20">  
                                    <h:outputText value="#{item.subStrategicName}" />
                                </p:column>
                                
                                <p:column width="20">  
                                    <h:outputText value="#{item.planName}" />
                                </p:column>
                                
                                <p:column width="20">  
                                    <h:outputText value="#{item.projectName}" />
                                </p:column>
                                
                                <p:column width="20">  
                                    <h:outputText value="#{item.workDetail}" />
                                </p:column>

                                <p:column>  
                                    <h:outputText value="#{item.goalType}" />
                                </p:column>

                                <p:column style="text-align: right">
                                    <h:outputText value="#{item.goalAmount}" />
                                </p:column>

                                <p:column>  
                                    <h:outputText value="#{item.goalResult}" />  
                                </p:column>
                                <p:column>  
                                    <h:outputText value="#{item.resultAmount}" />  
                                </p:column>

                                <p:column>
                                    <h:outputText value="#{item.practiceResult}" />
                                </p:column>

                                <p:column style="text-align: right">
                                    <h:outputText value="#{item.budgetSet}">
                                        <f:convertNumber pattern="###,###" type="currency"/>
                                    </h:outputText>
                                </p:column>

                                <p:column style="text-align: right">
                                    <h:outputText value="#{item.budgetReal}">
                                        <f:convertNumber pattern="###,###" type="currency"/>
                                    </h:outputText>
                                </p:column>
                                <p:column style="text-align: right"> 
                                    <h:outputText value="#{(item.budgetReal*100)/item.budgetSet}%" />
                                </p:column>
                                <p:column>  
                                    <h:outputText value="#{item.isIsPass()?'ผ่าน':'ไม่ผ่าน'}" />
                                </p:column>
                                <f:facet name="footer">

                                </f:facet>
                            </p:dataTable>

                            <p:dataTable id="rptPreSendListDetail" var="item" value="#{report001SummaryController.lazyModelDetail}" rendered="#{report001SummaryController.viewDetail}"
                                         paginator="true" rows="50" emptyMessage="#{msg.no_data_found}" rowIndexVar="index"
                                         currentPageReportTemplate="#{msg.current_pagereport_template}" resizableColumns="true"
                                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                         rowsPerPageTemplate="50,100,200">

                                <p:columnGroup type="header">  
                                    <p:row>  
                                        <p:column rowspan="2" headerText="ยุทธศาสตร์" width="320"/> 
                                        <p:column rowspan="2" headerText="โครงการ" width="320"/>  
                                        <p:column rowspan="2" headerText="กิจกรรม" width="320"/>
                                        <p:column rowspan="1" colspan="2" headerText="งบประมาณ" />
                                        <p:column rowspan="2" headerText="ร้อยละ" />
                                    </p:row>  

                                    <p:row>  
                                        <p:column headerText="ตั้งไว้" />
                                        <p:column headerText="จ่ายจริง" />
                                    </p:row>
                                </p:columnGroup>
                                <p:column>
                                    <h:outputText value="#{item.strategicName}" />
                                </p:column>

                                <p:column>  
                                    <h:outputText value="#{item.projectName}" />
                                </p:column>

                                <p:column>  
                                    <h:outputText value="#{item.activityName}" />
                                </p:column>
                                
                                <p:column style="text-align: right">
                                    <h:outputText value="#{item.budgetSet}">
                                        <f:convertNumber pattern="###,###" type="currency"/>
                                    </h:outputText>
                                </p:column>

                                <p:column style="text-align: right">
                                    <h:outputText value="#{item.budgetReal}">
                                        <f:convertNumber pattern="###,###" type="currency"/>
                                    </h:outputText>
                                </p:column>
                                <p:column style="text-align: right"> 
                                    <h:outputText value="#{report001SummaryController.setPercen(item.budgetReal, item.budgetSet)}%" />
                                </p:column>
                                <f:facet name="footer">

                                </f:facet>
                            </p:dataTable>
                        </h:panelGroup>
                    </p:panel>
                </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
</html>